<?php;
class attention_controller_attention extends SnsController {
	public function __construct($app, $controller){
		parent::__construct($app, $controller);
		$this->o = new attention_model_attention();
	}
	
	public function add_action(){
		$this->requireLogin();
		$this->_renderJson();
		$uid = self::$login['uid'];
		$cuid = _('uid');
		if($uid == $cuid){
			$this->ret = self::failure('您不能自己关注自己');
			return ;
		}
		if($rs = $this->o->add($uid,$cuid)){
			if($rs = ERR_PARAMATER) $this->ret	=	self::failure('您已经关注过了！');
			else $this->ret	= self::success();
		}else{
			$this->ret	=	self::failure('添加失败');
		}
	}
	
	/**
	 * 取消关注
	 *
	 */
	public function cancel_action(){
		$this->requireLogin();
		$this->_renderJson();
		$uid = self::$login['uid'];
		$cuid = _('uid');
		
		if($this->o->cancel($uid,$cuid)){
			$this->ret = self::success();
		}
		else{
			$this->ret = self::failure('取消失败!');
		}
	}
}
?>